//
//  main.swift
//  C021_test_swift_language
//
//  Created by yao_yu on 15/7/13.
//  Copyright © 2015年 yao_yu. All rights reserved.
//

import Foundation

print("Hello, World!")

extension Array {
    
}



var a = [1,2,3,4]
var b = (a.indexOf(1))

extension String {
    func md5() -> String! {
        let str = self.cStringUsingEncoding(NSUTF8StringEncoding)
        let strLen = CUnsignedInt(self.lengthOfBytesUsingEncoding(NSUTF8StringEncoding))
        let digestLen = Int(CC_MD5_DIGEST_LENGTH)
        let result = UnsafeMutablePointer<CUnsignedChar>.alloc(digestLen)
        CC_MD5(str!, strLen, result)
        var md5String:NSMutableString
        md5String = NSMutableString()
        for i in 0..<digestLen {
            md5String.appendFormat("%02x", result[i])
        }
        result.destroy()
        return md5String as String
    }
}

print("11".md5())